<?php
/**
 * 诊断线上服务器的文件问题
 */

echo "========================================\n";
echo "线上服务器诊断\n";
echo "========================================\n\n";

// 检查文件是否存在
$files = [
    'application/service/MessageParser/Vendor1MessageParser.php',
    'application/service/MessageParser/Vendor2MessageParser.php',
    'application/service/MessageParser/MessageParserFactory.php',
    'application/service/MessageParser/MessageParserInterface.php',
];

echo "📋 检查文件存在性:\n";
echo "----------------------------------------\n";

foreach ($files as $file) {
    if (file_exists($file)) {
        $size = filesize($file);
        echo "✅ {$file} ({$size} bytes)\n";
    } else {
        echo "❌ {$file} 不存在\n";
    }
}

echo "\n";

// 检查文件内容
echo "🔍 检查Vendor2MessageParser.php内容:\n";
echo "----------------------------------------\n";

$vendor2File = 'application/service/MessageParser/Vendor2MessageParser.php';
if (file_exists($vendor2File)) {
    $content = file_get_contents($vendor2File);
    $lines = file($vendor2File);
    
    // 查找问题行
    echo "检查第75-85行:\n";
    for ($i = 74; $i < 85 && $i < count($lines); $i++) {
        echo ($i + 1) . ": " . rtrim($lines[$i]) . "\n";
    }
    
    echo "\n";
    
    // 检查是否有注释掉的字段
    if (preg_match('/\/\/\s*[\'"]cell_id/', $content)) {
        echo "⚠️  发现注释掉的cell_id字段\n";
    }
    if (preg_match('/\/\/\s*[\'"]lac/', $content)) {
        echo "⚠️  发现注释掉的lac字段\n";
    }
    if (preg_match('/\/\/\s*[\'"]ip/', $content)) {
        echo "⚠️  发现注释掉的ip字段\n";
    }
    if (preg_match('/\/\/\s*[\'"]version/', $content)) {
        echo "⚠️  发现注释掉的version字段\n";
    }
    
    echo "\n";
} else {
    echo "❌ 文件不存在\n";
}

// 尝试加载类
echo "🔍 尝试加载MessageParser类:\n";
echo "----------------------------------------\n";

try {
    require_once 'application/service/MessageParser/MessageParserInterface.php';
    echo "✅ MessageParserInterface 加载成功\n";
} catch (\Throwable $e) {
    echo "❌ MessageParserInterface 加载失败: " . $e->getMessage() . "\n";
}

try {
    require_once 'application/service/MessageParser/Vendor1MessageParser.php';
    echo "✅ Vendor1MessageParser 加载成功\n";
} catch (\Throwable $e) {
    echo "❌ Vendor1MessageParser 加载失败: " . $e->getMessage() . "\n";
}

try {
    require_once 'application/service/MessageParser/Vendor2MessageParser.php';
    echo "✅ Vendor2MessageParser 加载成功\n";
} catch (\Throwable $e) {
    echo "❌ Vendor2MessageParser 加载失败: " . $e->getMessage() . "\n";
}

try {
    require_once 'application/service/MessageParser/MessageParserFactory.php';
    echo "✅ MessageParserFactory 加载成功\n";
} catch (\Throwable $e) {
    echo "❌ MessageParserFactory 加载失败: " . $e->getMessage() . "\n";
}

echo "\n========================================\n";
echo "诊断完成\n";
echo "========================================\n";

